﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="IssueStockAdjustment.aspx.cs" Inherits="PresentationLayer.IssueStockAdjustment" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div align="center">
            <h1>Stock Adjustment Voucher</h1>
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Label ID="lblSuccess" runat="server" ForeColor="Red"></asp:Label>
                    <table width="33%">
                        <tr>
                            <td>
                                <table width="100%">
                                    <tr align="left">
                                        <td>Category</td>
                                        <td>
                                            <asp:DropDownList ID="ddlCategory" Name="ddlCategory" runat="server" AutoPostBack="True" OnTextChanged="ddlCategory_TextChanged"></asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr align="left">
                                        <td>Item Name</td>
                                        <td>
                                            <asp:DropDownList ID="ddlItemName" runat="server" OnTextChanged="ddlItemName_TextChanged" Width="250px"></asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr align="left">
                                        <td>Supplier Name</td>
                                        <td>
                                            <asp:DropDownList ID="ddlSupplierName" runat="server" Width="250px"></asp:DropDownList></td>
                                    </tr>
                                    <tr align="left">
                                        <td>Reason</td>
                                        <td>
                                            <asp:TextBox ID="txtReason" runat="server" TextMode="MultiLine" CausesValidation="True"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvReason" runat="server" ErrorMessage="* Please enter a reason" Text="*" ControlToValidate="txtReason" ForeColor="Red" Display="Dynamic" ValidationGroup="AddGrp"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <fieldset>
                                    <legend>Adjustment Detail</legend>
                                    <table width="100%">
                                        <tr align="left">
                                            <td>
                                                <asp:RadioButtonList ID="rbtnlAdjustDetail" runat="server">
                                                    <asp:ListItem Selected="True">Quantity to be adjusted</asp:ListItem>
                                                    <asp:ListItem>Current quantity in stock</asp:ListItem>
                                                </asp:RadioButtonList>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtAdjustDetail" runat="server" CausesValidation="True"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvAdjustDetail" runat="server" ErrorMessage="* Please enter a value" ForeColor="Red" ControlToValidate="txtAdjustDetail" Display="Dynamic" ValidationGroup="AddGrp">*</asp:RequiredFieldValidator>
                                                <asp:RangeValidator ID="rvAdjustDetail" runat="server" ErrorMessage="* Please enter a valid number" ControlToValidate="txtAdjustDetail" ForeColor="Red" MaximumValue="2147483647" MinimumValue="-2147483647" Type="Integer" ValidationGroup="AddGrp">*</asp:RangeValidator>
                                                <asp:Label ID="lblError1" runat="server" ForeColor="Red"></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                            </td>
                        </tr>
                        <tr align="center">
                            <td>
                                <br />
                                <asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" ValidationGroup="AddGrp" />
                                <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" UseSubmitBehavior="False" CausesValidation="False" />
                                <br />
                                <br />
                                <asp:ValidationSummary ID="ValidationSummaryAdd" runat="server" DisplayMode="List" ForeColor="Red" ValidationGroup="AddGrp" />

                            </td>
                        </tr>
                    </table>
                    <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
                    <br />
                    <hr />
                    <br />
                    <asp:GridView ID="gvAdjustDetail" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="gvAdjustDetail_RowCancelingEdit" OnRowEditing="gvAdjustDetail_RowEditing" OnRowUpdating="gvAdjustDetail_RowUpdating" OnRowDeleting="gvAdjustDetail_RowDeleting" Visible="False">
                        <Columns>
                            <asp:TemplateField HeaderText="Item Code" Visible="False">
                                <ItemTemplate>
                                    <asp:Label ID="lblItemCode" Text='<%# Eval("ItemCode")%>' runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Item Name">
                                <ItemTemplate>
                                    <asp:Label ID="lblItemName" Text='<%# Eval("ItemName")%>' runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Category">
                                <ItemTemplate>
                                    <asp:Label ID="lblCategoryName" Text='<%# Eval("CategoryName")%>' runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Supplier Name">
                                <ItemTemplate>
                                    <asp:Label ID="lblSupplierName" Text='<%# Eval("SupplierName")%>' runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Quantity">
                                <ItemTemplate>
                                    <asp:Label ID="lblAdjQuantity" Text='<%# Eval("AdjustQuantity")%>' runat="server" />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtAdjQuantity" Text='<%# Bind("AdjustQuantity")%>' runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="rfvAdjQty" runat="server" ErrorMessage="* Please enter a value" ForeColor="Red" ControlToValidate="txtAdjQuantity" Display="Dynamic" ValidationGroup="UpdateGrp">*</asp:RequiredFieldValidator>
                                    <asp:RangeValidator ID="rvAdjQty" runat="server" ErrorMessage="* Please enter a valid number" ControlToValidate="txtAdjQuantity" ForeColor="Red" MaximumValue="2147483647" MinimumValue="-2147483647" Type="Integer" ValidationGroup="UpdateGrp">*</asp:RangeValidator>
                                    <asp:Label ID="lblErrorSubmit1" runat="server" ForeColor="Red"></asp:Label>
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Adjustment Detail">
                                <ItemTemplate>
                                    <asp:Label ID="lblAdjDetail" Text='<%# Eval("AdjustCondition")%>' runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Reason">
                                <ItemTemplate>
                                    <asp:Label ID="lblReason" Text='<%# Eval("Reason")%>' runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField HeaderText="Edit" ShowEditButton="True" ShowHeader="True" ValidationGroup="UpdateGrp" />
                            <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ShowHeader="True" />
                        </Columns>
                    </asp:GridView>
                    <br />
                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" CausesValidation="False" OnClick="btnSubmit_Click" />
                    <br />
                    <br />
                    <asp:ValidationSummary ID="ValidationSummaryUpdate" runat="server" ValidationGroup="UpdateGrp" DisplayMode="List" ForeColor="Red" />
                    <asp:Label ID="lblErrorSubmit" runat="server" ForeColor="Red"></asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>
